Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
PUBLISH/SUBSCRIBE example
The
h-CustOrderWin6.wprocedure runs a separate window calledh-OrderWin.wto display details from the current Order. You can run this Order window multiple times.
![]()
To see how you can use
PUBLISHandSUBSCRIBEstatements to extend the communication between these procedures:
- Open
h-OrderWin.wand save it ash-OrderWin1b.w.- In
h-OrderWin1b.wdefine this internal procedure called ShipDateChange:
This code responds to an event published by the main window whenever the value of the ShipDate field changes. It receives both the Order Number and the new ShipDate as
INPUTparameters. If the Order Number matches the one displayed by this instance ofOrderWin, then the displayed ShipDate is changed to the value passed in, and thedateColorprocedure is run to flag it with a new background color if its value requires this warning signal.- Add this
SUBSCRIBEstatement to the procedure’s main block:
This sets up every running instance of
h-OrderWin.wto receive theShipDateChangeevent when theSOURCE-PROCEDUREh-CustOrderWinpublishes it. There might be multiple instances ofOrderWinthat have subscribed to the event. Under other circumstances, there could just as easily be multiple, completely different versions of the procedureShipDateChangein multiple different procedure files that do different things with the changed ShipDate information. The publisher has no reason to know or care.- In
h-CustOrderWin, go into the property sheet for the OrderBrowse and enable the ShipDate column.- Define this
LEAVEtrigger for the ShipDate field:
If the field value changes, the published event notifies all subscribers.
- Run the main window and click the Order Details button several times for different Orders to bring up multiple instances of
OrderWin.- Modify the ShipDate for one of those Orders, then tab out of the field.
The corresponding
OrderWininstance for that Order shows the new ShipDate, possibly with a different color, depending on the value of ShipDate, as this sequence shows:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |